﻿using System;
using System.Windows.Input;

namespace ULSDeobfuscator {

    /// <summary>
    /// Helper to display a wainting cursor for the whole application
    /// </summary>
    public class WaitingCursor : IDisposable {

        private Cursor _mCurrentCursor;

        public WaitingCursor() {
        
            Enable();
        }

        /// <summary>
        /// Sets the cursort to the waiting cursor
        /// </summary>
        public void Enable() {

            _mCurrentCursor = Mouse.OverrideCursor;
            Mouse.OverrideCursor = Cursors.Wait;
        }

        /// <summary>
        /// Restores the cursor to the default one
        /// </summary>
        public void Disable() {
            Mouse.OverrideCursor = _mCurrentCursor;
        }

        #region Implementation of IDisposable

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose() {
            Disable();
        }

        #endregion
    }
}
